

#include "Test.h"
#include "HashTable.h"




void test_HashTable01()
{
	int arr[] = { 10001, 11, 55, 24, 19, 12, 31 };
	open_address::HashTable<int, int> ht;
	for (auto& e : arr)
	{
		ht.Insert({ e, e });
	}
	std::cout << ht.Find(55) << std::endl;
	std::cout << ht.Erase(55) << std::endl;
	std::cout << ht.Find(55) << std::endl;
}

void test_HashTable02()
{
	open_address::HashTable<std::string, int> ht;
	ht.Insert({ "welk", 0 });
	ht.Insert({ "fglkj", 1 });
	ht.Insert({ "sdlj", 2 });
	ht.Insert({ "dlkjlsf", 3 });
	ht.Insert({ "jldkjf", 4 });
}

void test_HashTable03()
{
	hash_bucket::HashTable<std::string, int> ht;
	ht.Insert({ "welk", 0 });
	ht.Insert({ "fglkj", 1 });
	ht.Insert({ "sdlj", 2 });
	ht.Insert({ "dlkjlsf", 3 });
	ht.Insert({ "jldkjf", 4 });

	ht.Erase("welk");
	ht.Erase("jldkjf");
	ht.Erase("sdlj");
	ht.Erase("fglkj");
}



void test_set01()
{
	unordered_set<int> s = { 5, 8, 2, 1, 0, 4 };

	unordered_set<int>::iterator it = s.begin();
	while (it != s.end())
	{
		cout << *it << endl;
		++it;
	}
}

void test_map01()
{
	unordered_map<string, int> m = { {"haha", 1}, {"xixi", 2}, {"hehe", 3} };

	unordered_map<string, int>::iterator it = m.begin();
	while (it != m.end())
	{
		cout << it->first << ": " << it->second << endl;
		++it;
	}
	cout << endl;
}